/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package qltv;
import java.io.*;
import java.sql.*;
import java.net.*;
/**
 *
 * @author DELL
 */
public class server extends Thread
{
    Socket cs;
    ObjectInputStream in;
    //BufferedReader in;
    PrintWriter out;
    static Statement stm;

    public server(Socket cs) throws IOException
    {
        this.cs=cs;
        in  = new ObjectInputStream(new DataInputStream(cs.getInputStream()));
        //in = new BufferedReader( new InputStreamReader( cs.getInputStream()));
        out = new PrintWriter(cs.getOutputStream());
    }

    public void run()
    {
        try {
            while (true) {//vong lap de xu ly yc cua client nhieu lan
                String flag = (String) in.readObject(); //nhan co hieu dang chuoi
                if (flag.equals("Thoát")) {
                    break; //neu client goi co hieu="thoat" thi kt thread phuc vu client
                }
                if (flag.equals("Đăng Nhập")) {
                    //nhap();
                }
            }
            
            in.close();
            out.close();
            cs.close();
            System.out.println("client da ket thuc!");
            } catch (Exception ex) {
        }
    }

    private void KiemTraDangNhap() throws Exception
    {
        while(true)
        {
            KTDN kt = (KTDN) in.readObject(); //doc username va password
            if(kt==null)
            {
                break;
            }

            
        }
    }
}
